package com.djhu.newscollector.crawel.imp.wangyi;

import com.djhu.newscollector.core.entity.Response;
import com.djhu.newscollector.crawel.core.FilterResult;
import com.djhu.newscollector.crawel.core.IpFliter;
import com.djhu.newscollector.crawel.core.PageProcess;
import com.djhu.newscollector.crawel.core.Url;
import com.djhu.newscollector.crawel.imp.worker.NewsResponse;
import com.djhu.newscollector.crawel.imp.worker.WangyiNewsWorker;
import com.djhu.newscollector.crawel.net.HttpRequest;
import com.djhu.newscollector.crawel.net.HttpResponse;
import com.djhu.newscollector.crawel.net.Page;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * Created by zw on 2018/2/12.
 */
public class DefaultPageProcess implements PageProcess {
    private IpFliter fliter;
    private static Logger logger = LogManager.getLogger(WangyiNewsWorker.class.getName());

    @Override
    public Response process(Url url) {
        logger.info("url not process!!!" + url.getUrl());
//        FilterResult result = fliter.filter(url);
//        if(result.timeout() != -1){
//
//        }
        HttpRequest request = new HttpRequest();
        request.setUrl(url);
        HttpResponse response = new HttpResponse();
        response.setCode(200);
        response.setRequest(request);
        Page page = new Page();
        page.setResponse(response);
        NewsResponse newsResponse = new NewsResponse();
        newsResponse.setPage(page);
        return newsResponse;
    }
}